const db = require('../db/index')

exports.getUserInfo = (req, res) => {
  const id = req.user.id
  const sql = `select id, username, nickname, user_pic from user where id=?`
  db.query(sql, id, (err, results) => {
    if (err) {
      return res.cc(err)
    }
    if (results.length !== 1) {
      return res.cc('获取用户信息失败')
    }
    res.send({
      status: 0,
      message: '获取用户信息成功',
      data: results[0]
    })
  })
}